home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.7 KB | 166 lines | [TEXT/ToyS] |
- property kasMaxDepth : 1 -- Maximum folders to follow down
- property kasGoDeepOnCaps : true -- Go deeper if folder is all caps
- property kasBlankAfter : 40
-
-
- on run
- open {choose folder with prompt "Choose a folder or volume to catalog…"}
- end run
-
-
- on open fsObjs
- repeat with fsObj in fsObjs
- CreateCatalog(fsObj)
- end repeat
- end open
-
-
- property sLastLocation : {40, 60}
-
- global gasTitle
- global gasTotal
- global gasList
- global gasDone
- global gasColumn
-
- on CreateCatalog(fsObj)
- set progW to display progress titled ¬
- "Cataloging Disk" subtitled ¬
- "Scanning…" maximum 1 located at sLastLocation
-
- set gasDone to 0
- set gasColumn to 0
- set gasTotal to 0
- set gasList to {}
-
- set info to basic info for fsObj
- set gasTitle to catalog name of info
-
- if (the catalog kind of info is a folder) then
- set gasList to AddFolder(progW, 0, fsObj)
- CreateCatalogList(progW)
- end if
-
- set sLastLocation to screen location of (display progress progW)
- display progress progW with disposal
- end CreateCatalog
-
-
- on AddFolder(progW, depth, fsObj)
- set myList to {}
- set myFiles to {}
- set myFolders to {}
-
- set info to basic info for fsObj
- set dad to fsObj as string
- set cont to list folder fsObj
-
- display progress progW labeled (catalog name of info)
-
- repeat with f in cont
- set subObj to (dad & f) as alias
- set subInfo to basic info for subObj
- if (catalog kind of subInfo is a folder) and ¬
- ((depth < kasMaxDepth) or ¬
- (kasGoDeepOnCaps and IsCaps(f))) then
- set myFolders to myFolders & f
- else
- set myFiles to myFiles & f
- end if
- end repeat
-
- set gasTotal to gasTotal + 1 + (number of items of myFiles)
- set myList to {":" & (catalog name of info), myFiles, AddFolders(progW, dad, depth + 1, myFolders)}
-
- return myList
- end AddFolder
-
-
- on AddFolders(progW, dad, depth, subfolders)
- set myList to {}
-
- repeat with f in subfolders
- set myList to myList & {AddFolder(progW, depth, (dad & f) as alias)}
- end repeat
-
- return myList
- end AddFolders
-
-
- on CreateCatalogList(progW)
- display progress progW subtitled "Listing…" maximum gasTotal
-
- tell application "Tex-Edit Plus" to ¬
- set name of (make new window) to gasTitle
-
- repeat with f in gasList
- ListOne(progW, 0, f)
- end repeat
-
- tell window gasTitle of application "Tex-Edit Plus"
- delete character 1 -- first return
- set style of line 1 to bold
- end tell
- end CreateCatalogList
-
-
- on ListOne(progW, depth, fList)
- if (class of fList is list) then
- repeat with f in fList
- if (class of f is list) then
- ListOne(progW, depth + 1, f)
- else
- AddLine(progW, depth, f)
- end if
- end repeat
- else
- AddLine(progW, depth, fList)
- end if
- end ListOne
-
-
- on AddLine(progW, depth, txt)
- set isFolder to (first character of txt is ":")
- if isFolder then set txt to "◊ " & (text from character 2 to -1 of txt)
-
- if (depth > 1) then
- repeat with i from 2 to depth
- set txt to tab & txt
- end repeat
- end if
-
- tell window gasTitle of application "Tex-Edit Plus"
- copy return & txt to after last line
-
- if (not isFolder) then set depth to -1
-
- set color of last line to item (2 + depth) of ¬
- {black, blue, blue, red, magenta, green, cyan, yellow}
- end tell
-
- set gasColumn to gasColumn + 1
- set gasDone to gasDone + 1
-
- if (gasColumn is kasBlankAfter) then
- tell window gasTitle of application "Tex-Edit Plus" to copy return to after last line
- set gasColumn to 0
- end if
-
- display progress progW value 0
- end AddLine
-
-
- property sLowA : ASCII number "a"
- property sLowZ : ASCII number "z"
- property sAsc0 : ASCII number "0"
- property sAsc9 : ASCII number "9"
-
- on IsCaps(s)
- repeat with c in characters of s
- set n to ASCII number c
- if (n ≥ sLowA) and (n ≤ sLowZ) then return false
- if (n ≥ sAsc0) and (n ≤ sAsc9) then return false
- end repeat
- return true
- end IsCaps
-